package com.tsx.i18n.vo;

import lombok.Data;

@Data
public class R<T> {
    private final String status = "status";
    private boolean success;
    private int code;
    private String message;
    private T data;
    // 默认构造器
    public R() {
        this.success = true;
        this.code = 200;   // 默认为HTTP OK状态码
        this.message = ""; // 默认为空字符串
        this.data = null;  // 默认数据为空
    }

    // 带参构造器
    public R(boolean success, int code, String message, T data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> R<T> ok(T data) {
        return new R<>(true, 200, "success", data);
    }

    public static <T> R<T> fail(int code, String message) {
        return new R<>(false, code, message, null);
    }
}
